package com.zyh.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateDemo2 {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf1.format(date);
        System.out.println("format = " + format);
        String birthday = "2002-10-21 12:22:45";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = sdf2.parse(birthday);
        Date parse1 = sdf1.parse(birthday);
        System.out.println("parse1 = " + parse1);
        System.out.println("parse = " + parse.getTime());
    }
}
